What does the program print to the monitor?
The variable contains: 123
This program printed out the same thing as the first example program. However, this program did not initialize the variable and so had to put a value into it later.
The syntax of assignment statements is easy. Assignment statements look like this:
variableName = expression ;
An assignment statement asks for the computer to perform two steps, in order:
For example, the assignment statement:
sum = 32 + 8 ;
asks for two actions:
(May, 2002) Note: I've just spent six or so hours grading student programs from second semester computer science. Several programs were poorly written (and sometimes not working) because their authors forgot about these two steps of an assignment statement. Without this concept, an easy problem became difficult. Sometimes you really need to know this.